package com.sh.构造器模式;

public class Person {
    private String name;
    private int age;
    private String sex;


    public Person(Builder builder) {
        this.name = builder.name;
        this.age = builder.age;
        this.sex = builder.sex;
    }

    public static Builder builder() {
        return new Builder();
    }

    // Person.Builder().name("张三").age(20).sex("男").build();
    public static final class Builder {
        private String name;
        private int age;
        private String sex;

        public Person build() {
            return new Person(this);
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder age(int age) {
            this.age = age;
            return this;
        }

        public Builder sex(String sex) {
            this.sex = sex;
            return this;
        }


    }


}
